<!DOCTYPE html>
<html lang="en-US" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>02-Git的使用 | blog-fifi</title>
    <meta name="description" content="blog-fifi">
    <link rel="preload stylesheet" href="/blog-fifi/assets/style.7f8a11cd.css" as="style">
    <script type="module" src="/blog-fifi/assets/app.7423d81a.js"></script>
    <link rel="preload" href="/blog-fifi/assets/inter-roman-latin.2ed14f66.woff2" as="font" type="font/woff2" crossorigin="">
  <link rel="modulepreload" href="/blog-fifi/assets/chunks/framework.832357a3.js">
  <link rel="modulepreload" href="/blog-fifi/assets/chunks/theme.ea8c38f0.js">
  <link rel="modulepreload" href="/blog-fifi/assets/前端工具_02-Git的使用.md.f0b52d49.lean.js">
  <script id="check-dark-light">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-b2cf3e0b><!--[--><!--]--><!--[--><span tabindex="-1" data-v-c8616af1></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-c8616af1> Skip to content </a><!--]--><!----><header class="VPNav" data-v-b2cf3e0b data-v-7e5bc4a5><div class="VPNavBar has-sidebar" data-v-7e5bc4a5 data-v-94c81dcc><div class="container" data-v-94c81dcc><div class="title" data-v-94c81dcc><div class="VPNavBarTitle has-sidebar" data-v-94c81dcc data-v-f4ef19a3><a class="title" href="/blog-fifi/" data-v-f4ef19a3><!--[--><!--]--><!----><!--[-->blog-fifi<!--]--><!--[--><!--]--></a></div></div><div class="content" data-v-94c81dcc><div class="curtain" data-v-94c81dcc></div><div class="content-body" data-v-94c81dcc><!--[--><!--]--><div class="VPNavBarSearch search" style="--vp-meta-key:&#39;Meta&#39;;" data-v-94c81dcc><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg class="DocSearch-Search-Icon" width="20" height="20" viewBox="0 0 20 20" aria-label="search icon"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-94c81dcc data-v-7f418b0f><span id="main-nav-aria-label" class="visually-hidden" data-v-7f418b0f>Main Navigation</span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/blog-fifi/" tabindex="0" data-v-7f418b0f data-v-37adc828 data-v-8f4dc553><!--[-->Home<!--]--><!----></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/blog-fifi/%E5%89%8D%E7%AB%AF%E5%B7%A5%E5%85%B7/01-VS%20Code%E7%9A%84%E4%BD%BF%E7%94%A8.html" tabindex="0" data-v-7f418b0f data-v-37adc828 data-v-8f4dc553><!--[-->前端工具<!--]--><!----></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/blog-fifi/%E6%A1%86%E6%9E%B6/React/01%E8%84%9A%E6%89%8B%E6%9E%B6.html" tabindex="0" data-v-7f418b0f data-v-37adc828 data-v-8f4dc553><!--[-->前端基础<!--]--><!----></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/blog-fifi/%E6%A1%86%E6%9E%B6/React/01%E8%84%9A%E6%89%8B%E6%9E%B6.html" tabindex="0" data-v-7f418b0f data-v-37adc828 data-v-8f4dc553><!--[-->前端框架<!--]--><!----></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/blog-fifi/%E5%89%8D%E7%AB%AF%E5%B7%A5%E5%85%B7/01-VS%20Code%E7%9A%84%E4%BD%BF%E7%94%A8.html" tabindex="0" data-v-7f418b0f data-v-37adc828 data-v-8f4dc553><!--[-->其他<!--]--><!----></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-94c81dcc data-v-f6a63727><label title="toggle dark mode" data-v-f6a63727 data-v-a9c8afb8><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" aria-checked="false" data-v-a9c8afb8 data-v-f3c41672><span class="check" data-v-f3c41672><span class="icon" data-v-f3c41672><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-a9c8afb8><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-a9c8afb8><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></label></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-94c81dcc data-v-0394ad82 data-v-f6988cfb><!--[--><a class="VPSocialLink" href="https://github.com/feifei128/" aria-label="github" target="_blank" rel="noopener" data-v-f6988cfb data-v-c530cc0a><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-94c81dcc data-v-40855f84 data-v-764effdf><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-764effdf><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-764effdf><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg></button><div class="menu" data-v-764effdf><div class="VPMenu" data-v-764effdf data-v-e7ea1737><!----><!--[--><!--[--><!----><div class="group" data-v-40855f84><div class="item appearance" data-v-40855f84><p class="label" data-v-40855f84>Appearance</p><div class="appearance-action" data-v-40855f84><label title="toggle dark mode" data-v-40855f84 data-v-a9c8afb8><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" aria-checked="false" data-v-a9c8afb8 data-v-f3c41672><span class="check" data-v-f3c41672><span class="icon" data-v-f3c41672><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-a9c8afb8><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-a9c8afb8><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></label></div></div></div><div class="group" data-v-40855f84><div class="item social-links" data-v-40855f84><div class="VPSocialLinks social-links-list" data-v-40855f84 data-v-f6988cfb><!--[--><a class="VPSocialLink" href="https://github.com/feifei128/" aria-label="github" target="_blank" rel="noopener" data-v-f6988cfb data-v-c530cc0a><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-94c81dcc data-v-e5dd9c1c><span class="container" data-v-e5dd9c1c><span class="top" data-v-e5dd9c1c></span><span class="middle" data-v-e5dd9c1c></span><span class="bottom" data-v-e5dd9c1c></span></span></button></div></div></div></div><!----></header><div class="VPLocalNav" data-v-b2cf3e0b data-v-392e1bf8><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-392e1bf8><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="menu-icon" data-v-392e1bf8><path d="M17,11H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,11,17,11z"></path><path d="M21,7H3C2.4,7,2,6.6,2,6s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,7,21,7z"></path><path d="M21,15H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,15,21,15z"></path><path d="M17,19H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,19,17,19z"></path></svg><span class="menu-text" data-v-392e1bf8>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-392e1bf8 data-v-079b16a8><button data-v-079b16a8>Return to top</button><!----></div></div><aside class="VPSidebar" data-v-b2cf3e0b data-v-af16598e><div class="curtain" data-v-af16598e></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-af16598e><span class="visually-hidden" id="sidebar-aria-label" data-v-af16598e> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="group" data-v-af16598e><section class="VPSidebarItem level-0 collapsible has-active" data-v-af16598e data-v-c4656e6d><div class="item" role="button" tabindex="0" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><h2 class="text" data-v-c4656e6d>前端工具</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-c4656e6d><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-c4656e6d><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-c4656e6d><!--[--><div class="VPSidebarItem level-1 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E5%89%8D%E7%AB%AF%E5%B7%A5%E5%85%B7/01-VS%20Code%E7%9A%84%E4%BD%BF%E7%94%A8.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>01 VS Code</p><!--]--><!----></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link is-active has-active" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E5%89%8D%E7%AB%AF%E5%B7%A5%E5%85%B7/02-Git%E7%9A%84%E4%BD%BF%E7%94%A8.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>02 Git</p><!--]--><!----></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E5%89%8D%E7%AB%AF%E5%B7%A5%E5%85%B7/03-%E7%BD%91%E7%BB%9C%E6%8A%93%E5%8C%85%E5%92%8C%E4%BB%A3%E7%90%86%E5%B7%A5%E5%85%B7%EF%BC%9AWhistle.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>03 网络抓包和代理工具</p><!--]--><!----></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-af16598e><section class="VPSidebarItem level-0 collapsible collapsed" data-v-af16598e data-v-c4656e6d><div class="item" role="button" tabindex="0" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><h2 class="text" data-v-c4656e6d>前端基础</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-c4656e6d><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-c4656e6d><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-c4656e6d><!--[--><section class="VPSidebarItem level-1" data-v-c4656e6d data-v-c4656e6d><div class="item" role="button" tabindex="0" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><h3 class="text" data-v-c4656e6d>HTML</h3><!----></div><div class="items" data-v-c4656e6d><!--[--><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E6%A1%86%E6%9E%B6/React/01%E8%84%9A%E6%89%8B%E6%9E%B6.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>01 脚手架</p><!--]--><!----></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E6%A1%86%E6%9E%B6/React/02%E7%BB%84%E4%BB%B6.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>02 组件</p><!--]--><!----></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1" data-v-c4656e6d data-v-c4656e6d><div class="item" role="button" tabindex="0" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><h3 class="text" data-v-c4656e6d>CSS</h3><!----></div><div class="items" data-v-c4656e6d><!--[--><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E6%A1%86%E6%9E%B6/React/01%E8%84%9A%E6%89%8B%E6%9E%B6.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>01 脚手架</p><!--]--><!----></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E6%A1%86%E6%9E%B6/React/02%E7%BB%84%E4%BB%B6.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>02 组件</p><!--]--><!----></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1" data-v-c4656e6d data-v-c4656e6d><div class="item" role="button" tabindex="0" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><h3 class="text" data-v-c4656e6d>JS</h3><!----></div><div class="items" data-v-c4656e6d><!--[--><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E6%A1%86%E6%9E%B6/React/01%E8%84%9A%E6%89%8B%E6%9E%B6.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>01 脚手架</p><!--]--><!----></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E6%A1%86%E6%9E%B6/React/02%E7%BB%84%E4%BB%B6.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>02 组件</p><!--]--><!----></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1" data-v-c4656e6d data-v-c4656e6d><div class="item" role="button" tabindex="0" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><h3 class="text" data-v-c4656e6d>TS</h3><!----></div><div class="items" data-v-c4656e6d><!--[--><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E6%A1%86%E6%9E%B6/React/01%E8%84%9A%E6%89%8B%E6%9E%B6.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>01 脚手架</p><!--]--><!----></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E6%A1%86%E6%9E%B6/React/02%E7%BB%84%E4%BB%B6.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>02 组件</p><!--]--><!----></a><!----></div><!----></div><!--]--></div></section><!--]--></div></section></div><div class="group" data-v-af16598e><section class="VPSidebarItem level-0 collapsible has-active" data-v-af16598e data-v-c4656e6d><div class="item" role="button" tabindex="0" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><h2 class="text" data-v-c4656e6d>前端框架</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-c4656e6d><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-c4656e6d><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-c4656e6d><!--[--><section class="VPSidebarItem level-1" data-v-c4656e6d data-v-c4656e6d><div class="item" role="button" tabindex="0" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><h3 class="text" data-v-c4656e6d>React18</h3><!----></div><div class="items" data-v-c4656e6d><!--[--><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E6%A1%86%E6%9E%B6/React/01%E8%84%9A%E6%89%8B%E6%9E%B6.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>01 脚手架</p><!--]--><!----></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E6%A1%86%E6%9E%B6/React/02%E7%BB%84%E4%BB%B6.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>02 组件</p><!--]--><!----></a><!----></div><!----></div><!--]--></div></section><div class="VPSidebarItem level-1 is-link is-active has-active" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="/blog-fifi/%E5%89%8D%E7%AB%AF%E5%B7%A5%E5%85%B7/02-Git%E7%9A%84%E4%BD%BF%E7%94%A8.html" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>Vue3</p><!--]--><!----></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-af16598e><section class="VPSidebarItem level-0 collapsible collapsed" data-v-af16598e data-v-c4656e6d><div class="item" role="button" tabindex="0" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><h2 class="text" data-v-c4656e6d>其他</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-c4656e6d><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-c4656e6d><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-c4656e6d><!--[--><section class="VPSidebarItem level-1" data-v-c4656e6d data-v-c4656e6d><div class="item" role="button" tabindex="0" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><h3 class="text" data-v-c4656e6d>ChatGPT</h3><!----></div><div class="items" data-v-c4656e6d><!--[--><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="https://poe.com/" target="_blank" rel="noreferrer" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>接口 1</p><!--]--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" height="24px" viewbox="0 0 24 24" width="24px" class="icon" data-v-8f4dc553><path d="M0 0h24v24H0V0z" fill="none"></path><path d="M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5H9z"></path></svg></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="https://freegpt.one/" target="_blank" rel="noreferrer" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>接口 2</p><!--]--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" height="24px" viewbox="0 0 24 24" width="24px" class="icon" data-v-8f4dc553><path d="M0 0h24v24H0V0z" fill="none"></path><path d="M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5H9z"></path></svg></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-c4656e6d data-v-c4656e6d><div class="item" data-v-c4656e6d><div class="indicator" data-v-c4656e6d></div><a class="VPLink link link" href="https://chatbot.theb.ai/" target="_blank" rel="noreferrer" data-v-c4656e6d data-v-8f4dc553><!--[--><p class="text" data-v-c4656e6d>接口 3</p><!--]--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" height="24px" viewbox="0 0 24 24" width="24px" class="icon" data-v-8f4dc553><path d="M0 0h24v24H0V0z" fill="none"></path><path d="M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5H9z"></path></svg></a><!----></div><!----></div><!--]--></div></section><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-b2cf3e0b data-v-a494bd1d><div class="VPDoc has-sidebar has-aside" data-v-a494bd1d data-v-c4b0d3cf><!--[--><!--]--><div class="container" data-v-c4b0d3cf><div class="aside" data-v-c4b0d3cf><div class="aside-curtain" data-v-c4b0d3cf></div><div class="aside-container" data-v-c4b0d3cf><div class="aside-content" data-v-c4b0d3cf><div class="VPDocAside" data-v-c4b0d3cf data-v-3f215769><!--[--><!--]--><!--[--><!--]--><div class="VPDocAsideOutline" data-v-3f215769 data-v-ff0f39c8><div class="content" data-v-ff0f39c8><div class="outline-marker" data-v-ff0f39c8></div><div class="outline-title" data-v-ff0f39c8>On this page</div><nav aria-labelledby="doc-outline-aria-label" data-v-ff0f39c8><span class="visually-hidden" id="doc-outline-aria-label" data-v-ff0f39c8> Table of Contents for current page </span><ul class="root" data-v-ff0f39c8 data-v-9a431c33><!--[--><!--]--></ul></nav></div></div><!--[--><!--]--><div class="spacer" data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-c4b0d3cf><div class="content-container" data-v-c4b0d3cf><!--[--><!--]--><!----><main class="main" data-v-c4b0d3cf><div style="position:relative;" class="vp-doc _blog-fifi_%E5%89%8D%E7%AB%AF%E5%B7%A5%E5%85%B7_02-Git%E7%9A%84%E4%BD%BF%E7%94%A8" data-v-c4b0d3cf><div><!----><h2 id="常见操作" tabindex="-1">常见操作 <a class="header-anchor" href="#常见操作" aria-label="Permalink to &quot;常见操作&quot;">​</a></h2><h3 id="全局配置用户信息" tabindex="-1">全局配置用户信息 <a class="header-anchor" href="#全局配置用户信息" aria-label="Permalink to &quot;全局配置用户信息&quot;">​</a></h3><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git config --global user.name &quot;smyhvae&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;"></span></span>
<span class="line"><span style="color:#A6ACCD;">git config --global user.email &quot;smyhvae@163.com&quot;</span></span></code></pre></div><h2 id="分支的合并" tabindex="-1">分支的合并 <a class="header-anchor" href="#分支的合并" aria-label="Permalink to &quot;分支的合并&quot;">​</a></h2><h3 id="场景-基于-master-分支的代码-开发一个新的特性" tabindex="-1">场景：基于 master 分支的代码，开发一个新的特性 <a class="header-anchor" href="#场景-基于-master-分支的代码-开发一个新的特性" aria-label="Permalink to &quot;场景：基于 master 分支的代码，开发一个新的特性&quot;">​</a></h3><p>如果你直接在 master 分支上开发这个新特性，是不好的，万一你在开发<code>特性1</code>的时候，领导突然又要叫你去开发<code>特性2</code>，就不好处理了。难道开发的两个特性都提交到 master？一会儿提交特性 1 的 commit，一会儿提交特性 2 的 commit？这会导致 commit 记录很混乱。</p><p>所以，我给你的建议做法是：给每个特性都单独建一个的新的分支。</p><p>比如说，我专门给<code>特性1</code>建一个分支<code>feature_item_recommend</code>。具体做法如下：</p><p>（1）基于 master 分支，创建一个新的分支，起名为<code>feature_item_recommend</code>：</p><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">$ git checkout -b feature_item_recommend</span></span>
<span class="line"><span style="color:#A6ACCD;"></span></span>
<span class="line"><span style="color:#A6ACCD;">Switched to a new branch &#39;feature_item_recommend&#39;</span></span></code></pre></div><p>上面这行命令，相当于：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">branch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">feature_item_recommend</span><span style="color:#A6ACCD;">    </span><span style="color:#C3E88D;">//</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">创建新的分支</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">feature_item_recommend</span><span style="color:#A6ACCD;">  </span><span style="color:#C3E88D;">//切换到新的分支</span></span></code></pre></div><p>（2）在新的分支<code>feature_item_recommend</code>上，完成开发工作，并 commit 、push。</p><p>（3）将分支<code>feature_item_recommend</code>上的开发进度<strong>合并</strong>到 master 分支：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span><span style="color:#A6ACCD;">  </span><span style="color:#C3E88D;">//切换到master分支</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">feature_item_recommend</span><span style="color:#A6ACCD;">    </span><span style="color:#C3E88D;">//将分支</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">feature_item_recommend</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">的开发进度合并到</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">分支</span></span></code></pre></div><p>合并之后，<code>master</code>分支和<code>feature_item_recommend</code>分支会指向同一个位置。</p><p>（3）删除分支<code>feature_item_recommend</code>：</p><blockquote><p>既然 特性 1 开发完了，也放心地提交到 master 了，那我们就可以将这个分支删除了。</p></blockquote><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git branch -d feature_item_recommend</span></span></code></pre></div><p>注意，我们当前是处于<code>master</code>分支的位置，来删除<code>feature_item_recommend</code>分支。如果当前是处于<code>feature_item_recommend</code>分支，是没办法删除它自己的。</p><p>同理，当我转身去开发<code>特性2</code>的时候，也是采用同样的步骤。</p><h3 id="合并分支时-如果存在分叉" tabindex="-1">合并分支时，如果存在分叉 <a class="header-anchor" href="#合并分支时-如果存在分叉" aria-label="Permalink to &quot;合并分支时，如果存在分叉&quot;">​</a></h3><p><img src="http://img.smyhvae.com/20180610_1650.png" alt=""></p><p>比如说上面这张图中，最早的时候，master 分支是位于<code>C2</code>节点。我基于<code>C2</code>节点，new 出一个新的分支<code>iss53</code>，我在<code>iss53</code>上提交了好几个 commit。</p><p>现在，我准备把<code>iss53</code>上的几个 commit 合并到 master 上，此时发现，master 分支已经前进到 C4 了。那该怎么合并呢？</p><p>合并的命令仍然是：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">iss53</span></span></code></pre></div><p><strong>解释</strong>：</p><p>这次合并的实现，并不同于简单的并入方式。这一次，我的开发历史是从更早的地方开始分叉的。</p><p>由于当前 master 分支所指向的 commit (C4)并非想要并入分支（iss53）的直接祖先，Git 不得不进行一些处理。就此例而言，Git 会用两个分支的末端（C4 和 C5）和它们的共同祖先（C2）进行一次简单的三方合并计算。</p><p>Git 没有简单地把分支指针右移，而是对三方合并的结果作一新的快照，并自动创建一个指向它的 commit（C6）（如下图所示）。我们把这个特殊的 commit 称作合并提交（mergecommit），因为它的祖先不止一个。</p><p>值得一提的是 Git 可以自己裁决哪个共同祖先才是最佳合并基础；这和 CVS 或 Subversion（1.5 以后的版本）不同，它们需要开发者手工指定合并基础。所以此特性让 Git 的合并操作比其他系统都要简单不少。</p><p><img src="http://img.smyhvae.com/20180610_1710.png" alt=""></p><h3 id="解决合并时发生的冲突" tabindex="-1">解决合并时发生的冲突 <a class="header-anchor" href="#解决合并时发生的冲突" aria-label="Permalink to &quot;解决合并时发生的冲突&quot;">​</a></h3><p><img src="http://img.smyhvae.com/20180610_1740.png" alt=""></p><p>如果 feature1 和 feature2 修改的是同一个文件中<strong>代码的同一个位置</strong>，那么，把 feature1 合并到 feature2 时，就会产生冲突。这个冲突需要人工解决。步骤如下：</p><p>（1）手动修改文件：手动修改冲突的那个文件，决定到底要用哪个分支的代码。</p><p>（2）git add：解决好冲突后，输入<code>git status</code>，会提示<code>Unmerged paths</code>。这个时候，输入<code>git add</code>即可，表示：<strong>修改冲突成功，加入暂存区</strong>。</p><p>（3）git commit 提交。</p><p>然后，我们可以继续把 feature1 分支合并到 master 分支，最后删除 feature1、feature2。</p><p><strong>注意</strong>：两个分支的同一个文件的不同地方合并时，git 会自动合并，不会产生冲突。</p><p>比如分支 feture1 对 index.html 原来的第二行之前加入了一段代码。 分支 feature2 对 index.html 在原来的最后一行的后面加入了一段代码。 这个时候在对两个分支合并，git 不会产生冲突，因为两个分支是修改同一文件的不同位置。 git 自动合并成功。不管是 git 自动合并成功，还是在人工解决冲突下合并成功，提交之前，都要对代码进行测试。</p><h2 id="日常操作积累" tabindex="-1">日常操作积累 <a class="header-anchor" href="#日常操作积累" aria-label="Permalink to &quot;日常操作积累&quot;">​</a></h2><h3 id="修改密码-曲线救国" tabindex="-1">修改密码（曲线救国） <a class="header-anchor" href="#修改密码-曲线救国" aria-label="Permalink to &quot;修改密码（曲线救国）&quot;">​</a></h3><blockquote><p>网上查了很久，没找到答案。最终，在 cld 童鞋的提示下，采取如下方式进行曲线救国。</p></blockquote><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 设置当前仓库的用户名为空</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;">  </span><span style="color:#C3E88D;">user.name</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;&quot;</span></span></code></pre></div><p>然后，当我们再输入<code>git pull</code>等命令行时，就会被要求重新输入<em>新的</em>账号密码。此时，密码就可以修改成功了。最后，我们还要输入如下命令，还原当前仓库的用户名：</p><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git config user.name &quot;smyhvae&quot;</span></span></code></pre></div><h3 id="修改已经-push-的某次-commit-的作者信息" tabindex="-1">修改已经 push 的某次 commit 的作者信息 <a class="header-anchor" href="#修改已经-push-的某次-commit-的作者信息" aria-label="Permalink to &quot;修改已经 push 的某次 commit 的作者信息&quot;">​</a></h3><p>已经 push 的记录，如果要修改作者信息的话，只能 通过--force 命令。我反正是查了很久，但最终还是不敢用公司的仓库尝试。</p><p>参考链接：</p><ul><li><a href="https://segmentfault.com/q/1010000006999861" target="_blank" rel="noreferrer">git 修改已提交的某一次的邮箱和用户信息</a></li></ul><p>看最后一条答案。</p><ul><li><a href="http://baurine.github.io/2015/08/22/git_update_author.html" target="_blank" rel="noreferrer">修改 git repo 历史提交的 author</a></li></ul><h3 id="将-branch1的某个commit1合并到branch2当中" tabindex="-1">将 <code>branch1</code>的某个<code>commit1</code>合并到<code>branch2</code>当中 <a class="header-anchor" href="#将-branch1的某个commit1合并到branch2当中" aria-label="Permalink to &quot;将 `branch1`的某个`commit1`合并到`branch2`当中&quot;">​</a></h3><p>切换到 branch2 中，然后执行如下命令：</p><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git cherry-pick commit1</span></span></code></pre></div><h3 id="_20190118-修改-github-已提交的用户名和邮箱" tabindex="-1">20190118-修改 GitHub 已提交的用户名和邮箱 <a class="header-anchor" href="#_20190118-修改-github-已提交的用户名和邮箱" aria-label="Permalink to &quot;20190118-修改 GitHub 已提交的用户名和邮箱&quot;">​</a></h3><p>参考链接：（亲测有效）</p><ul><li><p><a href="https://cloud.tencent.com/developer/article/1352623" target="_blank" rel="noreferrer">修改 Git 全部 Commit 提交记录的用户名 Name 和邮箱 Email</a></p></li><li><p><a href="https://blog.csdn.net/yusufolu9/article/details/53706269" target="_blank" rel="noreferrer">Mac 运行 sh 文件，也就是传说中的 shell 脚本</a></p></li></ul><p>在执行<code>./email.sh</code>后，如果出现<code>permission denied</code>的错误，可以先执行<code>chmod 777 email.sh</code>，修改文件的权限。</p><h3 id="_20200520-将-git-项目迁移到另一个仓库" tabindex="-1">20200520-将 Git 项目迁移到另一个仓库 <a class="header-anchor" href="#_20200520-将-git-项目迁移到另一个仓库" aria-label="Permalink to &quot;20200520-将 Git 项目迁移到另一个仓库&quot;">​</a></h3><p>我们假设旧仓库的项目名称叫<code>old-repository</code>，新仓库的项目名称叫<code>new-repository</code>。操作如下：</p><p>（1）创建旧仓库的裸克隆：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">clone</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--bare</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://github.com/exampleuser/old-repository.git</span></span></code></pre></div><p>执行上述命令后，会在本地生成一个名叫 <code>old-repository.git</code>的文件夹。</p><p>（2）迁移到新仓库：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">old-repository.git</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--mirror</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://github.com/exampleuser/new-repository.git</span></span></code></pre></div><p>这样的话，项目就已经迁移到新仓库了。</p><p>注意，我们<strong>不需要</strong>手动新建一个空的新仓库，当我们执行上述命令之后，新仓库就已经自动创建好了。</p><p>参考链接：</p><ul><li><p><a href="https://help.github.com/cn/github/creating-cloning-and-archiving-repositories/duplicating-a-repository" target="_blank" rel="noreferrer">复制仓库</a></p></li><li><p><a href="https://moelove.info/2016/12/04/Git-%E6%9C%AC%E5%9C%B0%E4%BB%93%E5%BA%93%E5%92%8C%E8%A3%B8%E4%BB%93%E5%BA%93/" target="_blank" rel="noreferrer">Git 本地仓库和裸仓库</a></p></li></ul><h3 id="_2021-11-10-提交代码时-绕过-eslint-检查" tabindex="-1">2021-11-10-提交代码时，绕过 eslint 检查 <a class="header-anchor" href="#_2021-11-10-提交代码时-绕过-eslint-检查" aria-label="Permalink to &quot;2021-11-10-提交代码时，绕过 eslint 检查&quot;">​</a></h3><p>需求：提交代码时，绕过 eslint 检查</p><p>解决办法：用命令行提交，在命令做 git commit 的时候，末尾追加<code>--no-verify</code>。例如：</p><div class="language-bash"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">千古壹号的commit备注</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--no-verify</span></span></code></pre></div><h2 id="git-客户端推荐" tabindex="-1">git 客户端推荐 <a class="header-anchor" href="#git-客户端推荐" aria-label="Permalink to &quot;git 客户端推荐&quot;">​</a></h2><p>市面上的 Git 客户端我基本都用过了，我最推荐的一款 Git 客户端是：<a href="https://www.git-tower.com" target="_blank" rel="noreferrer">Tower</a> 或者 <a href="https://git-fork.com" target="_blank" rel="noreferrer">Fork</a>。</p><ul><li>GitUp：<a href="https://gitup.co/" target="_blank" rel="noreferrer">https://gitup.co/</a></li></ul><p>20180623 时，网上看了下 Git 客户端的推荐排名：</p><p><img src="http://img.smyhvae.com/20180623_1210.png" alt=""></p><p><strong>SmartGit</strong>：</p><p>商业用途收费， 个人用户免费：</p><p><img src="http://img.smyhvae.com/20180623_1305.png" alt=""></p><h2 id="推荐书籍" tabindex="-1">推荐书籍 <a class="header-anchor" href="#推荐书籍" aria-label="Permalink to &quot;推荐书籍&quot;">​</a></h2><ul><li>《pro.git 中文版》</li></ul><h2 id="推荐连接" tabindex="-1">推荐连接 <a class="header-anchor" href="#推荐连接" aria-label="Permalink to &quot;推荐连接&quot;">​</a></h2><h3 id="_2018-06" tabindex="-1">2018-06 <a class="header-anchor" href="#_2018-06" aria-label="Permalink to &quot;2018-06&quot;">​</a></h3><ul><li><a href="https://www.cnblogs.com/wangiqngpei557/p/6056624.html" target="_blank" rel="noreferrer">聊下 git pull --rebase</a></li></ul></div></div></main><footer class="VPDocFooter" data-v-c4b0d3cf data-v-face870a><!--[--><!--]--><!----><div class="prev-next" data-v-face870a><div class="pager" data-v-face870a><a class="pager-link prev" href="/blog-fifi/%E5%89%8D%E7%AB%AF%E5%B7%A5%E5%85%B7/01-VS%20Code%E7%9A%84%E4%BD%BF%E7%94%A8.html" data-v-face870a><span class="desc" data-v-face870a>Previous page</span><span class="title" data-v-face870a>01 VS Code</span></a></div><div class="has-prev pager" data-v-face870a><a class="pager-link next" href="/blog-fifi/%E5%89%8D%E7%AB%AF%E5%B7%A5%E5%85%B7/03-%E7%BD%91%E7%BB%9C%E6%8A%93%E5%8C%85%E5%92%8C%E4%BB%A3%E7%90%86%E5%B7%A5%E5%85%B7%EF%BC%9AWhistle.html" data-v-face870a><span class="desc" data-v-face870a>Next page</span><span class="title" data-v-face870a>03 网络抓包和代理工具</span></a></div></div></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-b2cf3e0b data-v-2f86ebd2><div class="container" data-v-2f86ebd2><!----><p class="copyright" data-v-2f86ebd2>Copyright © 2023-present fifi</p></div></footer><!--[--><!--]--></div></div>
    <script>__VP_HASH_MAP__ = JSON.parse("{\"框架_react_01脚手架.md\":\"f6d2dbf2\",\"images_qqcode.md\":\"610c7ae0\",\"前端工具_chrome浏览器.md\":\"e0fbb704\",\"前端工具_iconmoon.md\":\"bed7c50c\",\"前端工具_emmet in vs code.md\":\"b42f209f\",\"前端工具_webstorm的使用.md\":\"f6ff84ab\",\"前端工具_vs code的使用积累.md\":\"563f192c\",\"index.md\":\"4ea7a894\",\"前端工具_02-git的使用.md\":\"f0b52d49\",\"前端工具_mac安装和配置iterm2.md\":\"eda077e8\",\"框架_react_02组件.md\":\"ddcff680\",\"前端工具_sublime text在前端中的使用.md\":\"34b2d82c\",\"前端工具_03-网络抓包和代理工具：whistle.md\":\"d4126301\",\"前端工具_github的使用.md\":\"3da40bab\",\"前端工具_iterm2 _ ohmyzsh _ agnoster 搭建.md\":\"bc3938aa\",\"前端工具_atom在前端的使用.md\":\"370bc080\",\"前端工具_01-vs code的使用.md\":\"959a7ce4\"}")
__VP_SITE_DATA__ = JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"blog-fifi\",\"description\":\"blog-fifi\",\"base\":\"/blog-fifi/\",\"head\":[],\"appearance\":true,\"themeConfig\":{\"nav\":[{\"text\":\"Home\",\"link\":\"/\"},{\"text\":\"前端工具\",\"link\":\"/前端工具/01-VS Code的使用.md\"},{\"text\":\"前端基础\",\"link\":\"/框架/React/01脚手架.md\"},{\"text\":\"前端框架\",\"link\":\"/框架/React/01脚手架.md\"},{\"text\":\"其他\",\"link\":\"/前端工具/01-VS Code的使用.md\"}],\"sidebar\":[{\"text\":\"前端工具\",\"collapsed\":true,\"items\":[{\"text\":\"01 VS Code\",\"link\":\"/前端工具/01-VS Code的使用.md\"},{\"text\":\"02 Git\",\"link\":\"/前端工具/02-Git的使用.md\"},{\"text\":\"03 网络抓包和代理工具\",\"link\":\"/前端工具/03-网络抓包和代理工具：Whistle.md\"}]},{\"text\":\"前端基础\",\"collapsed\":true,\"items\":[{\"text\":\"HTML\",\"items\":[{\"text\":\"01 脚手架\",\"link\":\"/框架/React/01脚手架.md\"},{\"text\":\"02 组件\",\"link\":\"/框架/React/02组件.md\"}]},{\"text\":\"CSS\",\"items\":[{\"text\":\"01 脚手架\",\"link\":\"/框架/React/01脚手架.md\"},{\"text\":\"02 组件\",\"link\":\"/框架/React/02组件.md\"}]},{\"text\":\"JS\",\"items\":[{\"text\":\"01 脚手架\",\"link\":\"/框架/React/01脚手架.md\"},{\"text\":\"02 组件\",\"link\":\"/框架/React/02组件.md\"}]},{\"text\":\"TS\",\"items\":[{\"text\":\"01 脚手架\",\"link\":\"/框架/React/01脚手架.md\"},{\"text\":\"02 组件\",\"link\":\"/框架/React/02组件.md\"}]}]},{\"text\":\"前端框架\",\"collapsed\":true,\"items\":[{\"text\":\"React18\",\"items\":[{\"text\":\"01 脚手架\",\"link\":\"/框架/React/01脚手架.md\"},{\"text\":\"02 组件\",\"link\":\"/框架/React/02组件.md\"}]},{\"text\":\"Vue3\",\"link\":\"/前端工具/02-Git的使用.md\"}]},{\"text\":\"其他\",\"collapsed\":true,\"items\":[{\"text\":\"ChatGPT\",\"items\":[{\"text\":\"接口 1\",\"link\":\"https://poe.com/\"},{\"text\":\"接口 2\",\"link\":\"https://freegpt.one/\"},{\"text\":\"接口 3\",\"link\":\"https://chatbot.theb.ai/\"}]}]}],\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/feifei128/\"}],\"footer\":{\"copyright\":\"Copyright © 2023-present fifi\"},\"search\":{\"provider\":\"local\"}},\"locales\":{},\"scrollOffset\":90,\"cleanUrls\":false}")</script>
    
  </body>
</html>